/**
 * 路由配置文件
 * @author xiaoqiang <465633678@qq.com>
 * @created 2018/10/31 00:31:13
 */

const Router = require('koa-router')
// 创建主页路由实例
const home = new Router()
/**
 * 首页
 */
home.get('/', async (ctx) => {
  ctx.body = `
    <ul>
      <li><a href="/page/helloworld">/page/helloworld</a></li>
      <li><a href="/page/404">/page/404</a></li>
    </ul>
  `
})
// 获取page路由实例
const page = new Router()
/**
 * page页子路由
 */
page.get('/404', async (ctx) => {
  ctx.body = '404 not found'
}).get('/helloworld', async ctx => {
  ctx.body = 'hello world'
})
const router = new Router()
router.use('/', home.routes(), home.allowedMethods())
router.use('/page', page.routes(), page.allowedMethods())
module.exports = router